package com.changqin;

import static sun.jvm.hotspot.runtime.PerfMemory.start;

import java.util.concurrent.CyclicBarrier;

public class PlayerTool implements Runnable {

  private String player;

  private CyclicBarrier cyclicBarrier;

  public PlayerTool(String player, CyclicBarrier cyclicBarrier) {
    this.player = player;
    this.cyclicBarrier = cyclicBarrier;
  }

  public String getPlayer() {
    return player;
  }

  public void setPlayer(String player) {
    this.player = player;
  }


  @Override
  public void run() {
    try {
      System.out.println(this.getPlayer() + " 开始匹配玩家...");
      //findOtherPlayer();
      cyclicBarrier.await();

      System.out.println(this.getPlayer() + " 进行选择角色...");
      //choiceRole();
      System.out.println(this.getPlayer() + " 角色选择完毕等待其他玩家...");
      cyclicBarrier.await();

      System.out.println(this.getPlayer() + " 开始游戏,进行游戏加载...");
      //loading();
      System.out.println(this.getPlayer() + " 游戏加载完毕等待其他玩家加载完成...");
      cyclicBarrier.await();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
